package com.siblings.loan.ui.loan.adapter

import android.annotation.SuppressLint
import android.graphics.Color
import android.graphics.Typeface
import androidx.recyclerview.widget.RecyclerView
import com.siblings.lib_baseadapter.SIBRecyclerViewAdapter
import com.siblings.lib_baseadapter.SIBViewHolderHelper
import com.siblings.loan.R
import org.json.JSONObject

/**
 * Siblings
 * @Author wwdeng
 * @CreateTime: 2024/7/15 14:42
 * @Annotation：贷款申请 明细 适配器
 */
class SibLoanApplyDetailsAdapter(recyclerView: RecyclerView?) : SIBRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_loan_apply_detail) {
    override fun setItemChildListener(helper: SIBViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
    }

    @SuppressLint("SetTextI18n")
    override fun fillData(helper: SIBViewHolderHelper, position: Int, model: JSONObject) {
        val textTitle = helper.getTextView(R.id.textTitle)
        textTitle.text = model.optString("showName")

        val textValue = helper.getTextView(R.id.textValue)
        textValue.text = model.optString("showDetail")

        if (model.has("title") && model.optString("title") == "YES") {
            textTitle.setTextColor(Color.parseColor("#FF000000"))
            textTitle.setTypeface(Typeface.DEFAULT,Typeface.BOLD)

            textValue.setTextColor(Color.parseColor("#FF4DB673"))
            textValue.setTypeface(Typeface.DEFAULT,Typeface.BOLD)
        } else {
            textTitle.setTextColor(Color.parseColor("#FF666666"))
            textTitle.setTypeface(Typeface.DEFAULT,Typeface.NORMAL)

            textValue.setTextColor(Color.parseColor("#FF666666"))
            textValue.setTypeface(Typeface.DEFAULT,Typeface.NORMAL)
        }
    }
}